<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title class="index-title-html">后台登录-X-admin2.0</title>
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
    <meta http-equiv="Cache-Control" content="no-siteapp" />
    <link rel="stylesheet" href="../lib/layui/css/layui.css" >
    <link rel="stylesheet" href="../css/font.css">
    <link rel="stylesheet" href="../css/xadmin.css">
    <script src="../lib/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="../js/base.js"></script>

</head>
<body>
<div class="x-body">

    <!--<fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">-->
       <!--<legend>ddddddddddd</legend>-->
    <!--</fieldset>-->


    <form class="layui-form" action="">
        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label">关键字</label>
                <div class="layui-input-inline">
                    <input type="text" name="searchStr" autocomplete="off" placeholder="输入用户名或ID" class="layui-input">
                </div>
            </div>
        </div>

        <div class="layui-form-item">
            <div class="layui-input-block" style="text-align: right">


                <button type="button" class="layui-btn layui-btn-sm  layui-btn-primary">
                    <i class="layui-icon layui-icon-close "></i>取消</button>
                <button type="button" class="layui-btn layui-btn-sm layui-btn-danger">
                    <i class="layui-icon layui-icon-face-smile "></i>保存</button>
                <button type="button" class="layui-btn layui-btn-sm layui-btn-normal">
                    <i class="layui-icon layui-icon-add-circle"></i>添加</button>
                <button type="button" class="layui-btn layui-btn-sm layui-btn-normal">
                    <i class="layui-icon layui-icon-download-circle"></i>下载</button>
                <button type="button" class="layui-btn layui-btn-sm" lay-filter="formSubmit">
                    <i class="layui-icon  layui-icon-search"></i> 提交</button>
                <button type="reset"  class="layui-btn layui-btn-sm layui-btn-warm ">
                    <i class="layui-icon layui-icon-refresh-3" ></i>重置</button>
            </div>
        </div>
        <hr>
    </form>

    <div id="tableContend">
        <table  class="layui-hide" id="userList-tb"></table>
    </div>

</div>
</body>
</html>
<script>

var option =  {
    elem: '#userList-tb'
    ,height: 'full-140'
    ,width:'100%'
//    ,url: basePath+'loginAuth/userList' //数据接口
    ,page: true //开启分页
    //,data:data
    ,cols:
            [
                [{
                    "field": "loginTime",
                    "title": "LOGINTIME",
                    "width": "120",
                    "sort": false,
                    "type": "normal",
                    "colspan": 1,
                    "fixed": null,
                    "toolbar": null,
                    "templet": null,
                    "align": "center",
                    "style": null,
                    "event": null,
                    "rowspan": 1
                }, {
                    "field": "phone",
                    "title": "PHONE",
                    "width": "120",
                    "sort": false,
                    "type": "normal",
                    "colspan": 1,
                    "fixed": null,
                    "toolbar": null,
                    "templet": null,
                    "align": "center",
                    "style": null,
                    "event": null,
                    "rowspan": 1
                }, {
                    "field": "birth",
                    "title": "BIRTH",
                    "width": "120",
                    "sort": false,
                    "type": "normal",
                    "colspan": 1,
                    "fixed": null,
                    "toolbar": null,
                    "templet": null,
                    "align": "center",
                    "style": null,
                    "event": null,
                    "rowspan": 1
                }, {
                    "field": "logoffTime",
                    "title": "LOGOFFTIME",
                    "width": "120",
                    "sort": false,
                    "type": "normal",
                    "colspan": 1,
                    "fixed": null,
                    "toolbar": null,
                    "templet": null,
                    "align": "center",
                    "style": null,
                    "event": null,
                    "rowspan": 1
                }, {
                    "field": "lastUpdated",
                    "title": "LASTUPDATED",
                    "width": "120",
                    "sort": false,
                    "type": "normal",
                    "colspan": 1,
                    "fixed": null,
                    "toolbar": null,
                    "templet": null,
                    "align": "center",
                    "style": null,
                    "event": null,
                    "rowspan": 1
                }, {
                    "field": "passWord",
                    "title": "PASSWORD",
                    "width": "120",
                    "sort": false,
                    "type": "normal",
                    "colspan": 1,
                    "fixed": null,
                    "toolbar": null,
                    "templet": null,
                    "align": "center",
                    "style": null,
                    "event": null,
                    "rowspan": 1
                }, {
                    "field": "weiXin",
                    "title": "WEIXIN",
                    "width": "120",
                    "sort": false,
                    "type": "normal",
                    "colspan": 1,
                    "fixed": null,
                    "toolbar": null,
                    "templet": null,
                    "align": "center",
                    "style": null,
                    "event": null,
                    "rowspan": 1
                }, {
                    "field": "creator",
                    "title": "CREATOR",
                    "width": "120",
                    "sort": false,
                    "type": "normal",
                    "colspan": 1,
                    "fixed": null,
                    "toolbar": null,
                    "templet": null,
                    "align": "center",
                    "style": null,
                    "event": null,
                    "rowspan": 1
                }, {
                    "field": "isActive",
                    "title": "ISACTIVE",
                    "width": "120",
                    "sort": false,
                    "type": "normal",
                    "colspan": 1,
                    "fixed": null,
                    "toolbar": null,
                    "templet": null,
                    "align": "center",
                    "style": null,
                    "event": null,
                    "rowspan": 1
                }, {
                    "field": "email",
                    "title": "EMAIL",
                    "width": "120",
                    "sort": false,
                    "type": "normal",
                    "colspan": 1,
                    "fixed": null,
                    "toolbar": null,
                    "templet": null,
                    "align": "center",
                    "style": null,
                    "event": null,
                    "rowspan": 1
                }, {
                    "field": "userNo",
                    "title": "USERNO",
                    "width": "120",
                    "sort": false,
                    "type": "normal",
                    "colspan": 1,
                    "fixed": null,
                    "toolbar": null,
                    "templet": null,
                    "align": "center",
                    "style": null,
                    "event": null,
                    "rowspan": 1
                }, {
                    "field": "dateCreated",
                    "title": "DATECREATED",
                    "width": "120",
                    "sort": false,
                    "type": "normal",
                    "colspan": 1,
                    "fixed": null,
                    "toolbar": null,
                    "templet": null,
                    "align": "center",
                    "style": null,
                    "event": null,
                    "rowspan": 1
                }, {
                    "field": "gender",
                    "title": "GENDER",
                    "width": "120",
                    "sort": false,
                    "type": "normal",
                    "colspan": 1,
                    "fixed": null,
                    "toolbar": null,
                    "templet": null,
                    "align": "center",
                    "style": null,
                    "event": null,
                    "rowspan": 1
                }, {
                    "field": "userName",
                    "title": "USERNAME",
                    "width": "120",
                    "sort": false,
                    "type": "normal",
                    "colspan": 1,
                    "fixed": null,
                    "toolbar": null,
                    "templet": null,
                    "align": "center",
                    "style": null,
                    "event": null,
                    "rowspan": 1
                }, {
                    "field": "deptId",
                    "title": "DEPTID",
                    "width": "120",
                    "sort": false,
                    "type": "normal",
                    "colspan": 1,
                    "fixed": null,
                    "toolbar": null,
                    "templet": null,
                    "align": "center",
                    "style": null,
                    "event": null,
                    "rowspan": 1
                }, {
                    "field": "qq",
                    "title": "QQ",
                    "width": "120",
                    "sort": false,
                    "type": "normal",
                    "colspan": 1,
                    "fixed": null,
                    "toolbar": null,
                    "templet": null,
                    "align": "center",
                    "style": null,
                    "event": null,
                    "rowspan": 1
                },
                    {
                        //"field":"操作",
                        "title": "操作",
                        "width": "240",
                        "sort": false,
                        "align": "center",
                        "fixed": "right",
                        toolbar:'<div><a class="layui-btn layui-btn-xs" lay-event="detail">查看</a><a class="layui-btn layui-btn-xs" lay-event="auth">分配权限</a><a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a><a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a></div>'
                    }
                ]
            ]
    //,data:[]
}

/*
* [
 [{
 "field": "ID",
 "title": "ID",
 "width": "120",
 "sort": false,
 "align": "center"
 }, {
 "field": "USER_NAME",
 "title": "姓名",
 "width": "120",
 "sort": false,
 "align": "center"
 }, {
 "field": "USER_NO",
 "title": "登录名",
 "width": "120",
 "sort": false,
 "align": "center"
 }, {
 "field": "GENDER",
 "title": "性别",
 "width": "120",
 "align": "center"
 }, {
 "field": "IS_ACTIVE",
 "title": "状态",
 "width": "120",
 "sort": false,
 "align": "center"
 }, {
 "field": "PHONE",
 "title": "PHONE",
 "width": "120",
 "sort": false,
 "align": "center"
 }, {
 "field": "EMAIL",
 "title": "邮箱",
 "width": "120",
 "sort": false,
 "align": "center"
 }, {
 "field": "QQ",
 "title": "QQ",
 "width": "120",
 "sort": false,
 "align": "center"
 }, {
 "field": "WEI_XIN",
 "title": "微信",
 "width": "120",
 "sort": false,
 "align": "center"
 }, {
 "field": "CREATOR",
 "title": "创建人",
 "width": "120",
 "sort": false,
 "align": "center"
 }, {
 //"field":"操作",
 "title": "操作",
 "width": "240",
 "sort": false,
 "align": "center",
 "fixed": "right",
 toolbar:'<div><a class="layui-btn layui-btn-xs" lay-event="detail">查看</a><a class="layui-btn layui-btn-xs" lay-event="auth">分配权限</a><a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a><a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a></div>'
 }

 ]
 ]
* */
    layui.use(['table','layer'], function(){
        var form = layui.form,layer = layui.layer;
        var table = layui.table;
        var $ = layui.$;
        //监听提交

        var funcPath = sysAction.getFunctionPage();
        option.url = basePath+'loginAuth/userList?funcPath='+funcPath;
        //初始化table
        table.render(option);

        //table重载
        $("button[lay-filter='formSubmit']").click(function(){
            var searchStr = $("input[name='searchStr']").val()
            table.reload("userList-tb",{where:{searchStr:searchStr},page:{curr: 1}});
        });

        //删除用户
        $("button[lay-filter='delete']").click(function(){
            var r = $("input[type=radio]:checked")
            var tr = $("tr").has(r);
            var trindex = tr.attr("data-index")
            var id = tr.find(r).val();
            if(id != undefined){
                layer.confirm("确定要删除用户：",{icon: 3, title:'提示'},function(index){
                    $.ajax({
                        url:basePath+'loginAuth/userDelete',
                        dataType:"json",
                        type:"post",
                        data:{id:id},
                        success:function(rdata){
                            if(rdata.code==200){
                                $("tr[data-index="+trindex+"]").remove()
                            }
                            layer.msg(rdata.message)
                        }
                    })
                })
            }else{
                layer.msg("请选择要删除的用户")
            }
            //console.log(tr.find(r).val());
        });

    });

</script>

